<?php

class Sistema_Form_Usuariosesc extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        $this->setName('form');
        
        $el = new Zend_Form_Element_Hidden('USU_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))
            ->addFilter('Int');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_NOME');
        $el->setLabel('Nome Completo');
        $el->setAttrib('required',''); 
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_CPF');
        $el->setLabel('CPF');
        $el->setAttrib('required','');
        $el->setAttrib('class','cpf');        
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_CEP');
        $el->setLabel('CEP');
        $el->setAttrib('class','cep');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_EMAIL');
        $el->setLabel('E-mail');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_END');
        $el->setLabel('Endereço');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_TEL');
        $el->setLabel('Telefone');
        $el->setAttrib('class','telefone');  
        $this->addElement($el);

        // Empresa
        $obj = new Sistema_Model_DbTable_Empresa();
        $row = $obj->fetchAll('EMP_STA = 1')->toArray();
        $arr = array();
        foreach($row as $r) $arr[$r['EMP_ID']] = $r['EMP_NOM'];
        
        $el = new Zend_Form_Element_Select('EMP_ID',array('onchange' => ''));
        $el->setLabel('Empresas')
        ->setRequired(true)
        ->addMultiOptions($arr);
        $this->addElement($el);

        $el= new Zend_Form_Element_Text('USU_LOGIN');
        $el->setLabel('Login');
        $el->setAttrib('readonly','');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Password('USU_SENHA');
        $el->setLabel('Senha');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('USU_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('submit',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-button btn-ok');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        //$btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-button btn-cancel">Cancelar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-button btn-cancel');
        $this->addElement($btn);
        
    }


}

